import faker from 'faker'

// const list = new Array(100).map(v => {
//   console.log('v', v)
//   return {
//     name: faker.name.findName(),
//   }
// })

// let list = new Array(100).fill(null)
// list = list.map(v => {
//   return {
//     name: faker.fake("{{name.lastName}}{{name.firstName}}"),
//     title: faker.name.title,
//   }
// })


function generateUser() {
  return {
    id: faker.datatype.number(),
    name: faker.name.findName(),
    email: faker.internet.email(),
    website: faker.internet.url(),
    address: faker.address.streetAddress() + faker.address.city() + faker.address.country(),
    bio: faker.lorem.sentences(),
    image: faker.image.avatar(),
    createTime: faker.date.recent(),
    status: faker.random.arrayElement([1, 2]),
  }
}

const userList = (param) => {
  return {
    total: 200,
    list: Array.from(Array(param.pageSize), v => {
      return generateUser()
    })
  }
}

const currentUser = (param) => {
  return generateUser()
}

const resourceList = (param) => {
  return [
    {
      id: faker.datatype.uuid(),
      name: '示例',
      path: '/demo',
      children: [
        {
          id: faker.datatype.uuid(),
          name: '列表',
          path: '/demo2qw',
          children: [
            {
              id: faker.datatype.uuid(),
              name: '普通列表',
              path: '/demo/list',
            },
            {
              id: faker.datatype.uuid(),
              name: '树状列表',
              path: '/demo/tree-list',
            },
            {
              id: faker.datatype.uuid(),
              name: '测试',
              path: '/demo/test',
            },
          ]
        },
      ]
    },
    {
      id: faker.datatype.uuid(),
      name: '系统管理',
      path: '/user',
      children: [
        {
          id: faker.datatype.uuid(),
          name: '用户管理',
          path: '/user/list',
        },
        {
          id: faker.datatype.uuid(),
          name: '角色管理',
          path: '/role/list',
        },
      ]
    },
  ]
}

const changeStatus = (param) => {
  return {}
}

export default {
  '/api/users': userList,
  '/api/users/current': currentUser,
  '/api/users/resources': resourceList,
  '/api/users/status': changeStatus,
}
